package edu.software.argo.user.controller;

import edu.software.argo.user.service.UserService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")//这个注释用来指定访问路径的.GetMapping, PostMapping类似
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping("/regist")
    public String regist(HttpServletRequest request, HttpServletResponse response,
                         HttpSession session){
        String username = request.getParameter("username");
        return "main";
    }

    @RequestMapping("/login")
    //下面这个注解RequestParam用来获取请求的参数；PathVariable能获取路径中的参数
    public String login(@RequestParam(name = "username") String name,
                        @RequestParam(value ="pageNum",defaultValue = "1") int pageNum){
       //括号里的相当于 String name = request.getParameter("username");
        userService.login();
        return "login success";
    }
}
